package com.ruoyi.signin.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.signin.domain.Signin;
import com.ruoyi.signin.service.ISigninService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 签到信息Controller
 * 
 * @author dlh
 * @date 2024-12-05
 */
@RestController
@RequestMapping("/signin/signin")
public class SigninController extends BaseController
{
    @Autowired
    private ISigninService signinService;

    /**
     * 查询签到信息列表
     */
    @PreAuthorize("@ss.hasPermi('signin:signin:list')")
    @GetMapping("/list")
    public TableDataInfo list(Signin signin)
    {
        startPage();
        List<Signin> list = signinService.selectSigninList(signin);
        return getDataTable(list);
    }

    /**
     * 导出签到信息列表
     */
    @PreAuthorize("@ss.hasPermi('signin:signin:export')")
    @Log(title = "签到信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Signin signin)
    {
        List<Signin> list = signinService.selectSigninList(signin);
        ExcelUtil<Signin> util = new ExcelUtil<Signin>(Signin.class);
        util.exportExcel(response, list, "签到信息数据");
    }

    /**
     * 获取签到信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('signin:signin:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(signinService.selectSigninById(id));
    }

    /**
     * 新增签到信息
     */
    @PreAuthorize("@ss.hasPermi('signin:signin:add')")
    @Log(title = "签到信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Signin signin)
    {
        return toAjax(signinService.insertSignin(signin));
    }

    /**
     * 修改签到信息
     */
    @PreAuthorize("@ss.hasPermi('signin:signin:edit')")
    @Log(title = "签到信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Signin signin)
    {
        return toAjax(signinService.updateSignin(signin));
    }

    /**
     * 删除签到信息
     */
    @PreAuthorize("@ss.hasPermi('signin:signin:remove')")
    @Log(title = "签到信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(signinService.deleteSigninByIds(ids));
    }
}
